package com.assets.room.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;

import com.assets.room.entity.CheckData;

import java.util.List;

@Dao
public interface CheckDataDao {

    @Insert
    void insertCheckData(CheckData checkData);
    @Insert
    void insertCheckData(List<CheckData> checkData);

    @Query("DELETE FROM asset_check_data")
    void deleteAllData();

    @Query("SELECT * FROM asset_check_data")
    List<CheckData> getAllCheckData();

    @Query("SELECT * FROM asset_check_data WHERE asset_number = :asset_number")
    CheckData getAllCheckData(String asset_number);

    @Query("UPDATE asset_check_data SET check_result = :state, is_flag = :is_flag WHERE asset_number = :asset_number AND check_id = :check_id")
    void updateById(String state, String is_flag, String asset_number, String check_id);

    @Query("UPDATE asset_check_data SET check_result = :state WHERE asset_number = :asset_number AND check_id = :check_id")
    void updateById(String state, String asset_number, String check_id);

    @Query("SELECT * FROM asset_check_data WHERE check_result = :check_result AND check_id = :check_id")
    List<CheckData> getCheckByResult(String check_result, String check_id);

    @Query("SELECT * FROM asset_check_data WHERE check_id = :check_id")
    List<CheckData> getAllAssetCheckData(Long check_id);



    @Query("SELECT * FROM asset_check_data WHERE check_id = :check_id")
    CheckData getAssetCheckData(Long check_id);

    @Query("SELECT * FROM asset_check_data WHERE check_result = :check_result AND check_id = :check_id")
    List<CheckData> getAssetCheckByStatus(String check_result, Long check_id);

    @Query("SELECT * FROM asset_check_data WHERE is_flag = :is_flag")
    List<CheckData> getAssetCheckByFlag(String is_flag);

    @Query("SELECT * FROM asset_check_data WHERE asset_number = :asset_number AND check_id = :check_id")
    CheckData getCheckDataById(String asset_number, String check_id);

//    @Query("SELECT * FROM asset_check_data WHERE asset_number = :asset_number AND check_id = :check_id")
//    CheckData getCheckDataById(String asset_number, String check_id);

    @Query("SELECT * FROM asset_check_data WHERE check_id = :check_id")
    CheckData getCheckDataById(String check_id);


    @Query("UPDATE asset_check_data SET check_result = :state, is_flag = :isFlag WHERE check_result = :check_result AND check_id = :check_id")
    void updateByIdLoss(String state, String isFlag,  String check_result, String check_id);
}
